<template>
  <div class="common-layout">
    <el-container style="min-height: 100vh">
      <el-aside
        :width="store.isCollapse ? '64px' : '200px'"
        style="background: #001529; transition: all 0.5s"
      >
        <Aside />
      </el-aside>
      <el-container>
        <el-header class="header">
          <el-icon @click="store.isCollapse = !store.isCollapse">
            <Fold v-show="!store.isCollapse" />
            <Expand v-show="store.isCollapse" />
          </el-icon>
          <!-- <el-icon><Fold /></el-icon>
          <el-icon><Expand /></el-icon> -->

          <el-space>
            <span>欢迎你, {{ adminname }}</span>
            <el-button @click="exit">退出</el-button>
          </el-space>
        </el-header>
        <el-main>
          <div style="height: 100%; background-color: #fff; padding: 20px">
            <RouterView />
          </div>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script lang="ts" setup>
import Aside from "./components/Aside.vue";
import { useHomeStore } from "@/stores/home";
import { useRouter } from "vue-router";

const store = useHomeStore();
const router = useRouter();

const exit = (): void => {
  sessionStorage.clear();
  router.push("/login");
};

const adminname = sessionStorage.getItem("adminname");
</script>

<style lang="less" scoped>
.header {
  background-color: #fff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 16px;
}
</style>
